$(function(){
	//后台修改密码接口url
	var url = "/o2oSystem/local/changelocalpwd";
	//从地址栏获取usertype
	var usertype = getQueryString("usertype");
	
	//提交后台
	$("#submit").click(function(){
		//原账号
		var username = $("#username").val();
		//原密码
		var password = $("#password").val();
		//新密码
		var newPassword = $("#newPassword").val();
		var confirmPassword = $("#confirmPassword").val();
		if(newPassword != confirmPassword){
			$.toast("两次输入密码不一致");
			return;
		}
		//添加表单数据
		var formData = new FormData();
		formData.append("username",username);
		formData.append("password",password);
		formData.append("newPassword",newPassword);
		//验证码
		var verifyCodeActual = $("#j_captcha").val();
		if(!verifyCodeActual){
			$.toast("请输入验证码");
			return;
		}
		formData.append("verifyCodeActual",verifyCodeActual);
		
		//ajax发送
		$.ajax({
			url:url,
			type:"post",
			dataType:"json",
			data:formData,
			cache:false,
			processData:false,
			contentType:false,
			success:function(data){
				if(data.success){
					$.toast("修改成功");
					if(usertype == 1){
						window.location.href="/o2oSystem/frontend/index";
					}else{
						window.location.href="/o2oSystem/shopadmin/shoplist";
					}
				}else{
					$.toast("提交失败");
					console.log(data.errMsg);
					$("#captcha_img").click();
				}
			}
		});
	});
	//点击返回
	$("#back").click(function(){
		window.location.href="/o2oSystem/shopadmin.shoplist";
	});
})